<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width">
  <title>Title</title>
  <style>
    .note {
      background: #fff;
      border-radius: 16px;
      padding: 0 16px 16px 16px;
      margin-top: 30px;
      border-top: 2px solid #ccc;
      box-shadow: 0 0 16px -12px #333 inset;
    }
    .note h2 {
      background: #f0f0f0;
      padding: 8px 20px;
      font-weight: normal;
      border-radius: 25px;
    }
    .note h4 {
      margin: 0;
    }
    .note p {
      line-height: 24px;
      margin: 0;
      color: #555;
    }
    .note-item {
      margin-top: 12px;
    }
  </style>
</head>
<body>
<header></header>
<div id="app">
  {{ 1 | sexText('cn') }}
  <div :id="0 | sexText">
    <button @click="handleClick">小按钮</button>
  </div>
  <div class="note">
    <h2>课程笔记</h2>
    <div class="note-item">
      <h4>1. 使用过滤器的场景？</h4>
      <p></p>
    </div>
    <div class="note-item">
      <h4>2. 如何定义过滤器？</h4>
      <p></p>
    </div>
    <div class="note-item">
      <h4>3. 怎么使用过滤器？可以在哪里使用？</h4>
      <p></p>
    </div>
    <div class="note-item">
      <h4>4. 如何进行编程式的调用？</h4>
      <p></p>
    </div>
  </div>
</div>
<footer></footer>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
  (function () {
    Vue.filter('sexText', function (sex, ct) {
      if (sex === 0) {
        return '女'
      }
      if (sex === 1) {
        return '男1'
      }
      return '未知'
    })
    new Vue({
      el: '#app',
      methods: {
        handleClick () {
          const filter = Vue.filter('sexText')
          console.log(filter(1))
        }
      },
      filters: {
        sexText (sex, ct) {
          console.log('ct', ct)
          if (sex === 0) {
            return '女'
          }
          if (sex === 1) {
            return '男'
          }
          return '未知'
        }
      }
    })
  })()
</script>
</body>
</html>
